<?php

namespace app\common\cachemodel\chat\hz;

use app\common\model\BaseCache;

class HzHzQuestion extends BaseCache
{
    protected $table = 'haozhungpt_ai.hz_question';

    protected $cacheModel = 'chat.hz_hz_question';

    /**
     * @param array $ids
     * @param array|null $type
     * @param string $sortType
     * @return array
     */
    public function getInfoByIdsInData($ids, $type, $sortType)
    {
        try
        {
            $data = $this
                ->where(['id' => ['in', $ids]])
                ->column('id,status,need_recode,question,relation_type,ouput_type', 'id');

        }
        catch (\Exception $e)
        {
            $data = [];
        }

        return $data;
    }

    public function batchGetInfoByIds($cids, $field = [])
    {
        $resData = parent::batchGetInfoByIds($cids, $field);

        return $this->dataInit($resData);
    }

    /**
     * 数据初始化
     * @param array $data
     * @return array
     */
    public function dataInit(array $data)
    {
        foreach ($data as $index => $itemData)
        {
            $data[$index] = arrayKeyData2int($itemData, ['id', 'status', 'need_recode', 'relation_type', 'ouput_type']);
        }

        return $data;
    }

}